package metaphor.persistence;

import metaphor.persistence.filter.SearchCriteria;
import metaphor.persistence.filter.Query;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * Data Access Object
 * @author Mark Ashworth
 */
public interface Dao {
    /**
     * Retrieves all the persistent objects
     * @param persistentClass The persistent class to retrieve for
     * @return List<Object>
     * @throws org.springframework.dao.DataAccessException If there was an database error
     */
    List retrieve(Class persistentClass);
    
    /**
     * Retrieves all the persistent objects
     * @param persistentClass The persistent class to retrieve for
     * @param type The entity type to return
     * @return List<Object>
     * @throws org.springframework.dao.DataAccessException If there was an database error
     */
    List retrieve(Class persistentClass, DaoMode type);
    
    /**
     * Retrieves the persistent object by id
     * @param persistentClass The persistent class to retrieve for
     * @param id The id of the persistent object
     * @return Object
     * @throws org.springframework.dao.DataAccessException If there was an database error
     */
    Object retrieveById(Class persistentClass, Serializable id);
    
	/**
	 * Retrieves a list of objects
	 * @param query The query for the list of objects to retrieve
	 * @return List<Object>
     * @throws org.springframework.dao.DataAccessException If there was an database error
	 */
	List retrieve(Query query);
    
    /**
	 * Retrieves a list of objects by a search criteria
	 * @param searchCriteria The search criteria for the list of objects to retrieve
	 * @return List<T>
	 * @throws org.springframework.dao.DataAccessException If there was an database error
	 */
	List retrieve(SearchCriteria searchCriteria);
    
    /**
	 * Deletes the object
	 * @param object The object to delete
     * @throws org.springframework.dao.DataAccessException If there was an database error
	 */
	void delete(Object object);
    
    /**
     * Deletes a list of persistent objects
     * @param objects The objects to delete
     * @throws org.springframework.dao.DataAccessException If there was an database error
     */
    void delete(List<Object> objects);
    
    /**
     * Persists the object
     * @param object The object to persist
     * @return The persisted object
     * @throws org.springframework.dao.DataAccessException If there was an database error
     */
    Object persist(Object object);
    
    /**
     * Persists the XML element to the database
     * @param persistentClass The persistent class that the XML represents
     * @param xml The xml element to persist
     * @return The persisted object
     * @throws org.springframework.dao.DataAccessException If there was an database error
     */
    Object persist(Class persistentClass, String xml);
    
    /**
     * Persists an object map to the database
     * @param object The object map to persist
     * @return The persisted object
     * @throws org.springframework.dao.DataAccessException If there was an database error
     */
    Object persist(Map object);
}
